package pkg

import (
	"github.com/golang-jwt/jwt/v5"
	"time"
)

type MyCustomClaims struct {
	UserId int `json:"UserId"`
	jwt.RegisteredClaims
}

func Token(UserId int) (string, error) {
	// Create claims with multiple fields populated
	claims := MyCustomClaims{
		UserId,
		jwt.RegisteredClaims{
			// A usual scenario is to set the expiration time relative to the current time
			ExpiresAt: jwt.NewNumericDate(time.Now().Add(24 * time.Hour)),
		},
	}

	token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
	ss, err := token.SignedString([]byte("LTAI5t8yeTaoFpNPhd1uj4FC"))
	return ss, err
}
